// 创建主题上下文

import React, { createContext, useContext, useState } from 'react';

// 创建主题上下文
const ThemeContext = createContext({
    isDarkMode: false,
    toggleTheme: () => {},
});

// 创建主题提供者
export const ThemeProvider = ({ children }) => {
    const [isDarkMode, setIsDarkMode] = useState(false);

    const toggleTheme = () => {
        setIsDarkMode((prevMode) => !prevMode);
    };

    return (
        <ThemeContext.Provider value={{ isDarkMode, toggleTheme }}>
            {children}
        </ThemeContext.Provider>
    );
};

// 自定义 Hook，便于获取主题状态
export const useTheme = () => useContext(ThemeContext);

